<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author boscaru
 * @export Modules
 * @export-metadata RequiredRoles:ROLE_PROFESSOR
 */
class MisCursos extends Module {

    public function index() {

        $NIT = $this->currentUser->getName();
        $Cursos = $this->model->courses->GetByDocente("NIT");
        $this->assign("Cursos", $Cursos);
        $this->assign("action", $this->route->action("loadStudents"));
        $this->display("index");
         
     }

    public function loadStudents() {
        Loader::using("models::entities::CursoPk");
        Loader::using("models::entities::PeriodoAcademico");
        
        $CursoPk = new CursoPk();
        $CursoPk->setCodigoMateria($this->request->get("CodigoMateria"));
        $CursoPk->setCodigoPlan($this->request->get("CodigoPlan"));
        $CursoPk->setGrupo($this->request->get("Grupo"));
        $CursoPk->setSemestre($this->request->get("Semestre"));
        
        $config = ModulesContext::instance()->getConfig();
        $periodosParams = explode("-", $config->periodoActual);
        $periodo = new PeriodoAcademico();
        $periodo->setAno($periodosParams[0]);
        $periodo->setPeriodo($periodosParams[1]);
        
        $CursoPk->setPerdiodoAcademico($periodo);

        $Curso = $this->model->courses->GetById($CursoPk);
        $Estudiantes = $this->model->students->GetListaEstudianteByCurso($CursoPk);

        $this->assign("Estudiantes", $Estudiantes);
        $this->assign("Curso", $Curso);
        $this->assign("UrlVolver", $this->route->action("index"));
        $this->assign("link", $this->route->moduleAction("Mensajes", "compose"));
        $this->display();
    }

}

?>
